package com.iwhalecloud.bss.kite.cucc.service.route.impl;

import java.util.Map;
import java.util.Objects;

import org.springframework.stereotype.Component;

import com.iwhalecloud.bss.kite.common.chain.HandlerExecutionChain;
import com.iwhalecloud.bss.kite.cucc.client.dto.inf.InfServContextDTO;
import com.iwhalecloud.bss.kite.cucc.service.route.InfServReqParam;
import com.iwhalecloud.bss.kite.cucc.service.route.match.impl.CommonMatchHandler;
import com.iwhalecloud.bss.kite.cucc.service.route.strategy.IInfServStrategy;

@Component
public class DefaultInfServRoute extends AbstractInfServRoute {

    /**
     * Description: <br>
     * 路由策略匹配处理配注册
     * 
     * @taskId <br>
     *         <br>
     */
    public void registerStrategyMatchHandler(HandlerExecutionChain<InfServReqParam> chain) {
        // 添加默认策略匹配
        if (Objects.nonNull(chain)) {
            // 商品分类匹配
            chain.addHandler(new CommonMatchHandler());
        }
    }

    /**
     * Description: <br>
     * 获取工单信息
     * 
     * @author XXZ<br>
     * @taskId <br>
     * @param context
     * @return <br>
     */
    @Override
    public Map<String, Object> getWorkOrderInfo(InfServContextDTO context) {

        InfServReqParam param = new InfServReqParam();
        param.setOrderSource(context.getOrderSource());
        // 2.计算调用接口策略
        IInfServStrategy infServStrategy = getInfServStrategy(param);

        return infServStrategy.getWorkOrderInfo(context.getOrderId(), context.getFlowId(), context.getTaskId());
    }
}
